package com.xunfang.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xunfang.bean.Owner;
import com.xunfang.bean.Result;
import com.xunfang.mapper.OwnerMapper;
import com.xunfang.service.OwnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author yellow Doctor
 * @date 2025-09-16
 * @desc https://blog.csdn.net/hekai7217
 */
@Service
public class OwnerServiceImpl implements OwnerService {

    @Autowired
    private OwnerMapper ownerMapper;

    @Override
    public Result<PageInfo> selectAllOwners(Integer currentPage, Integer pageSize) {

        //01 分页
        PageHelper.startPage(currentPage,pageSize);

        //02 查询所有
        List<Owner> owners = ownerMapper.selectAllOwners();

        //03 组装数据
        PageInfo<Owner> pageInfo = new PageInfo<>(owners);

        return Result.ok(pageInfo);
    }

    @Override
    public void updateOwner(Owner owner) {
         ownerMapper.updateOwner(owner);
    }

}
